package com.project.controller;

import com.project.common.R;
import com.project.entity.Member;
import com.project.entity.TeacherMember;
import com.project.service.ProMemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/member")
public class ProMemberController {
    @Autowired
    private ProMemberService proMemberService;
    //查询单个用户
    @GetMapping("/student/{identity}")
    public R<Member> getOne( @PathVariable int identity,@RequestParam(required = false) Long userId) throws Exception {
            if(userId==null){
                return R.success(new Member());
            }
            Member member = proMemberService.getMember(userId, identity);
            return R.success(member);

    }
    //查询老师单个用户
    @GetMapping("/teacher/{identity}")
    public R<TeacherMember> getTeacher( @PathVariable int identity, @RequestParam Long userId) throws Exception {

        TeacherMember member = proMemberService.getMemberTeacher(userId, identity);
        return R.success(member);

    }




}
